Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 2 - Finder Objects / The Finder Application Object


Properties and Elements of the Finder

The Finder application, like most other Finder objects, has many properties you can refer to in scripts. Some of these properties provide a shorthand method
of referring to certain specialized objects.

For example, although the Finder application can contain any number of folders, only one Apple Menu Items folder can be located in the active System Folder for a given Macintosh computer. The Apple Menu Items folder can be described in a script as either an element of the System Folder or a property
of the Finder application.

This script identifies the Apple Menu Items folder as an object contained by the System Folder:

tell application "Finder"   open folder "Apple Menu Items" of ¬
      folder "System Folder" of startup disk
end tell
This script identifies the Apple Menu Items folder as a property of the Finder application:

tell application "Finder"   open apple menu items folder
end tell
Other specialized containers, such as the startup disk, the System Folder,
the Startup Items folder, and the Extensions folder, are also defined as
Finder properties.

Note
You can use the Path To scripting addition command
to obtain references to some of the objects that can be identified as properties of the Finder. However, Path To use its own constants for these references and returns a pathname as an AppleScript reference of the form alias "Disk:Folder1:Folder2:...:Filename".
The desktop is another container you can identify as a property of the Finder. Any items contained by the desktop--that is, items that are "loose" on the working area of your screen and not contained by a folder, disk, or other object--can be considered elements of either the desktop or of the Finder application object, as shown in the following examples.

This script requests a list of the items contained by the desktop:

tell application "Finder"   items of desktop
end tell

--result: {trash of application "Finder", disk 
"Applications" of application "Finder", disk "Storage" of 
application "Finder", startup disk of application "Finder"}
If you request the items of the Finder application, you get a similar list:

tell application "Finder"   items
end tell

--result: {trash of application "Finder", disk 
"Applications" of application "Finder", disk "Storage" of 
application "Finder", startup disk of application "Finder", 
desktop of application "Finder"}
The only difference is that the second list includes a reference to the desktop itself, which is also an item contained by the Finder application.

Finally, if you request the contents of the Finder application, you get a list that includes references to windows and to currently running processes as well as to the Finder's items:

tell application "Finder"   contents
end tell

--result: {trash of application "Finder", disk 
"Applications" of application "Finder", disk "Storage" of 
application "Finder", startup disk of application "Finder", 
window of startup disk of application "Finder", content 
space of desktop of application "Finder", desktop of 
application "Finder", application "Scriptable Text Editor", 
application "Script Editor"}
For complete lists of the Finder application object's properties and element classes, see the definition for the Application object class, which begins on page 31.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996